package cn.gson.fengboot.controller;

import cn.gson.fengboot.model.pojos.Dbusiness;
import cn.gson.fengboot.model.pojos.Dcount;
import cn.gson.fengboot.model.pojos.DmoneyVo;
import cn.gson.fengboot.model.service.DbusstatiService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/busstati")
public class DbusstatiController {
    @Autowired
    DbusstatiService dbusstatiService;

    @Autowired
    DbusinessController controller;

    /*折线图我的商机本季度数据*/
    @RequestMapping("/selectByQUARTERMonthSize")
    public List<Map<String, Object>> selectByQUARTERMonthSize(HttpServletRequest session){
        String getbuspeople = controller.getbuspeople(session);
        return dbusstatiService.selectByQUARTERMonthSize(getbuspeople);
    }


    /*折线图我可查看商机本季度数据*/
    @RequestMapping("/selectByQUARTERMonthSizemyall")
    public List<Map<String, Object>> selectByQUARTERMonthSizemyall(HttpServletRequest request){
        return dbusstatiService.selectByQUARTERMonthSizemyall(request);
    }

    /*折线图我可查看商机本年数据**/
    @RequestMapping("/selectByMonthSizemyall")
    public List<Map<String,Object>> selectByMonthSizemyall(HttpServletRequest request){
        return dbusstatiService.selectByMonthSizemyall(request);
    }

    /*折线图我的商机本年数据*/
    @RequestMapping("/selectByMonthSize")
    public List<Map<String,Object>> selectByMonthSize(HttpServletRequest session){
        String getbuspeople = controller.getbuspeople(session);
        return dbusstatiService.selectByMonthSize(getbuspeople);
    }

    /*折线图过去5年我可查看数据*/
    @RequestMapping("/selectByyearfiveSizemyall")
    public List<Map<String,Object>> selectByyearfiveSizemyall(HttpServletRequest request){
        return dbusstatiService.selectByyearfiveSizemyall(request);
    }

    /*折线图过去5年我的商机数据*/
    @RequestMapping("/selectByyearfiveSize")
    public List<Map<String,Object>> selectByyearfiveSize(HttpServletRequest session){
        String getbuspeople = controller.getbuspeople(session);
        return dbusstatiService.selectByyearfiveSize(getbuspeople);
    }



    /*漏斗我的商机阶段数据*/
    @RequestMapping("/selectByphase")
    public List<Dcount> selectByphase(HttpServletRequest session){
        String getbuspeople = controller.getbuspeople(session);
        return dbusstatiService.selectByphase(getbuspeople);
    }

    /*漏斗我可查看商机阶段数据*/
    @RequestMapping("/selectByphasemyall")
    public List<Dcount> selectByphasemyall(HttpServletRequest request){
        return dbusstatiService.selectByphasemyall(request);
    }


    /*我的商机地图*/
    @RequestMapping("/selectBySheng")
    public List<Dcount> selectBySheng(HttpServletRequest session){
        String getbuspeople = controller.getbuspeople(session);
        return dbusstatiService.selectBySheng(getbuspeople);
    }


    /*我可查看数据地图*/
    @RequestMapping("/selectByShengmyall")
    public List<Dcount> selectByShengmyall(HttpServletRequest request){
        return dbusstatiService.selectByShengmyall(request);
    }


    /*我的商机统计饼状图*/
    @RequestMapping("/selectByMoney")
    public  List<DmoneyVo> selectByMoney(HttpServletRequest session){
        String getbuspeople = controller.getbuspeople(session);
        return dbusstatiService.selectByMoney(getbuspeople);
    }

    /*我可查看商机统计饼状图*/
    @RequestMapping("/selectByMoneymyall")
    public  List<DmoneyVo> selectByMoneymyall(HttpServletRequest request){
        return dbusstatiService.selectByMoneymyall(request);
    }

    /*我的商机本季度的商机*/
    @RequestMapping("/selectByQUARTERData")
    public Map<String,Object> selectByQUARTERData(HttpServletRequest request,Integer currentpage, Integer pagesize,HttpServletRequest session){
        String getbuspeople = controller.getbuspeople(session);
        Page<Object> obj = PageHelper.startPage(currentpage, pagesize);
        Map<String,Object> map = new HashMap<>();
        dbusstatiService.selectByQUARTERData(getbuspeople);
        map.put("total",obj.getTotal());
        map.put("rows",obj.getResult());
        return map;
    }

    /*我可查看商机表格本季度*/
    @RequestMapping("/selectByQUARTERDatamyall")
    public Map<String,Object> selectByQUARTERDatamyall(HttpServletRequest request,Integer currentpage, Integer pagesize){
        Page<Object> obj = PageHelper.startPage(currentpage, pagesize);
        Map<String,Object> map = new HashMap<>();
        dbusstatiService.selectByQUARTERDatamyall(request);
        map.put("total",obj.getTotal());
        map.put("rows",obj.getResult());
        return map;
    }

    /*我的商机本年份的商机*/
    @RequestMapping("/selectByYearData")
    public Map<String,Object> selectByYearData(Integer currentpage, Integer pagesize,HttpServletRequest session){
        String getbuspeople = controller.getbuspeople(session);
        Page<Object> obj = PageHelper.startPage(currentpage, pagesize);
        Map<String,Object> map = new HashMap<>();
        dbusstatiService.selectByYearData(getbuspeople);
        map.put("total",obj.getTotal());
        map.put("rows",obj.getResult());
        return map;
    }

    /*我的商机过去5年的商机*/
    @RequestMapping("/selectByFiveYearData")
    public Map<String,Object> selectByFiveYearData(Integer currentpage, Integer pagesize,HttpServletRequest session){
        String getbuspeople = controller.getbuspeople(session);
        Page<Object> obj = PageHelper.startPage(currentpage, pagesize);
        Map<String,Object> map = new HashMap<>();
        dbusstatiService.selectByFiveYearData(getbuspeople);
        map.put("total",obj.getTotal());
        map.put("rows",obj.getResult());
        return map;
    }

}
